package com.t17;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * Created by xuyiwei on 2018/8/13.
 */
class StringAddress{
    private String s;
    public StringAddress(String s) {
        this.s = s;
    }
    public String toStringg(){
        return super.toString()+" "+s;
    }
}
public class FillingLists {
    public static void main(String[] args) {
        List<StringAddress> list = new ArrayList<StringAddress>( Collections.nCopies(4,new StringAddress("Hellow")));
        System.out.println(list);
        Collections.fill(list,new StringAddress("Word!"));
        System.out.println(list);
        /**
         [com.t17.StringAddress@49476842, com.t17.StringAddress@49476842, com.t17.StringAddress@49476842, com.t17.StringAddress@49476842]
         [com.t17.StringAddress@78308db1, com.t17.StringAddress@78308db1, com.t17.StringAddress@78308db1, com.t17.StringAddress@78308db1]
         */
    }
}
